<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h2>Editar Docente</h2>

            <p:panel styleClass="container_24 clearfix " style="background: none; border: none;"> 
                <h:form id="form" acceptcharset="utf-8">
                    <p:growl id="msg" life="3000" autoUpdate="true" showDetail="false"/>

                    <p class="subtitle">Dados Gerais</p>

                    <p:outputLabel value="Curso:" styleClass="grid_3" for="cursoSelectCheckboxMenu"
                                   rendered="#{managerCriarDocente.admin}"/>
                    <div class="grid_8">
                        <p:selectOneMenu id="cursoSelectCheckboxMenu"
                                         value="#{managerPesquisarDocente.cursoPesquisar}" 
                                         label="Selecione o curso" filter="true"
                                         filterMatchMode="contains"
                                         converter="cursoconverter" rendered="#{managerCriarDocente.admin}"
                                         caseSensitive="false" panelStyle="width:220px">
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{managerPesquisarDocente.cursos}" var="item" 
                                           itemLabel="#{item.nome}" itemValue="#{item}" />  
                            <p:ajax update=":form:disciplinaSelectCheckboxMenu" 
                                    listener="#{managerPesquisarDocente.handleMudarDisciplinas}" />
                        </p:selectOneMenu>
                    </div>
                    <div class="clear" />

                    <p:outputLabel value="Docente:" styleClass="grid_3" for="docenteInputText" />
                    <p:inputText id="docenteInputText" styleClass="grid_8"
                                 value="#{managerPesquisarDocente.docentePesquisar.nome}" />

                    <p:outputLabel value="Situação:" styleClass="grid_3" for="situacaoSelectOneMenu" />
                    <div class="grid_8">
                        <p:selectOneMenu id="situacaoSelectOneMenu" styleClass="grid_8"
                                         value="#{managerPesquisarDocente.docentePesquisar.situacao}" panelStyle="width: 220px" >
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{managerPesquisarDocente.situacao}"/>
                        </p:selectOneMenu>
                    </div>
                    <div class="clear" />

                    <p:outputLabel value="Área:" styleClass="grid_3" for="areaInputText" />
                    <p:inputText id="areaInputText" styleClass="grid_19"
                                 value="#{managerPesquisarDocente.docentePesquisar.area}" />

                    <div class="clear"/>

                    <p:outputLabel value="Disciplinas:" styleClass="grid_3" />
                    <p:selectCheckboxMenu id="disciplinaSelectCheckboxMenu"
                                          value="#{managerPesquisarDocente.disciplinasSelecionadas}" 
                                          label="Selecione a(s) disciplina(s)" filter="true"
                                          filterMatchMode="contains" styleClass="grid_8" 
                                          converter="disciplinaconverter"
                                          caseSensitive="false" panelStyle="width:290px">
                        <f:selectItems value="#{managerPesquisarDocente.disciplinasPesquisar}" 
                                       var="item" itemLabel="#{item.nome}" itemValue="#{item}" />  
                    </p:selectCheckboxMenu>

                    <div class="clear"/>
                    <div class="buttonAction">
                        <p:commandButton value="Pesquisar" icon="ui-icon-search" 
                                         actionListener="#{managerPesquisarDocente.pesquisar()}" 
                                         update="@form" styleClass="ui-priority-primary"/>

                    </div>
                    
                    <p class="subtitle">Resultado</p>

                    <p:dataTable id="cursoDataTable" value="#{managerPesquisarDocente.docentes}" var="item"
                                 styleClass="grid_24" emptyMessage="Nenhum registro">

                        <f:facet name="header">
                            Disciplinas
                        </f:facet>

                        <p:column headerText="Ação" width="50">
                            <p:button title="Editar"
                                      href="editardocente.xhtml?eDocente=#{item.id}"
                                      icon="ui-icon-pencil"/>
                            <p:button title="Visualizar"
                                      href="visualizardocente.xhtml?vDocente=#{item.id}"
                                      icon="ui-icon-zoomin"/>
                            <p:commandButton update="@form" title="Excluir"
                                             oncomplete="dlg.show()"
                                             icon="ui-icon-trash" >
                                <f:setPropertyActionListener target="#{managerPesquisarDocente.docenteDelete}" value="#{item}" />
                            </p:commandButton>
                        </p:column>

                        <p:column headerText="Nome">  
                            #{item.nome}
                        </p:column>
                        
                        <p:column headerText="Curso">  
                            #{managerPesquisarDocente.cursos(item)}
                        </p:column>

                        <p:column headerText="Disciplinas" width="150" style="text-align: center">  
                            #{managerPesquisarDocente.disciplinas(item)}
                        </p:column> 

                    </p:dataTable>

                    <p:dialog id="modalDialog" header="Confirmação de remoção" widgetVar="dlg" modal="true" 
                              height="80" closable="true" resizable="false" >
                        <h:outputText value="Tem certeza que deseja remover este docente?" />
                        <div class="buttonAction">
                            <p:commandButton value="Sim"
                                             actionListener="#{managerPesquisarDocente.deletar()}"
                                             update="@form"
                                             icon="ui-icon-check"/>
                            <p:commandButton value="Não" icon="ui-icon-close"
                                             oncomplete="dlg.hide()" />

                        </div>
                    </p:dialog>
                    
                    <div class="clear"/>
                    <div class="buttonAction">
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w"
                                  href="indexdocente.xhtml"/>
                    </div>
                </h:form>
            </p:panel> 
        </ui:define>
    </ui:composition>
</html>